#include "transpose_op.h"
#include "../../matrix/matrix.h"
#include "../../factory/factory.h"
#include "../../factory/transpose_factory.h"

Transpose::Transpose(Node* node) : OpNode({node}){
}

vector<Node*> Transpose::getGradNodes(Node* grad) {
    Factory* factory = new TransposeFactory(grad);
    Node* ret_grad = factory -> createNode();
    delete factory;
    return {ret_grad};
}

void Transpose::compute(Context* context) {
    auto nodes = *getNodeIn();
    context -> setFlowedData(this, 
            context -> getFlowedData(nodes[0]).transpose());
}
